using Senparc.Weixin.Entities;
using Senparc.Weixin.HttpUtility;
using Senparc.Weixin.MP.AdvancedAPIs.Poi;
using Senparc.Weixin.MP.CommonAPIs;
using System;
using System.Collections.Generic;
namespace Senparc.Weixin.MP.AdvancedAPIs
{
	public static class PoiApi
	{
		public static UploadImageResultJson UploadImage(string accessTokenOrAppId, string file, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<UploadImageResultJson>(delegate(string accessToken)
			{
				string url = string.Format("https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token={0}", accessToken);
				Dictionary<string, string> fileDictionary = new Dictionary<string, string>();
				return Post.PostFileGetJson<UploadImageResultJson>(url, null, fileDictionary, null, null, timeOut);
			}, accessTokenOrAppId, true);
		}
		public static WxJsonResult AddPoi(string accessTokenOrAppId, CreateStoreData createStoreData, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				string urlFormat = string.Format("http://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token={0}", accessToken);
				return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, createStoreData, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static GetStoreResultJson GetPoi(string accessTokenOrAppId, string poiId, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<GetStoreResultJson>(delegate(string accessToken)
			{
				string urlFormat = string.Format("http://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token={0}", accessToken);
				var data = new
				{
					poi_id = poiId
				};
				return CommonJsonSend.Send<GetStoreResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static GetStoreListResultJson GetPoiList(string accessTokenOrAppId, int begin, int limit = 20, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<GetStoreListResultJson>(delegate(string accessToken)
			{
				string urlFormat = string.Format("http://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token={0}", accessToken);
				var data = new
				{
					begin,
					limit
				};
				return CommonJsonSend.Send<GetStoreListResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static WxJsonResult DeletePoi(string accessTokenOrAppId, string poiId, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				string urlFormat = string.Format("http://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token={0}", accessToken);
				var data = new
				{
					poi_id = poiId
				};
				return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static WxJsonResult UpdatePoi(string accessTokenOrAppId, UpdateStoreData updateStoreData, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				string urlFormat = string.Format("http://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token={0}", accessToken);
				return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, updateStoreData, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static GetCategoryResult GetCategory(string accessTokenOrAppId)
		{
			return ApiHandlerWapper.TryCommonApi<GetCategoryResult>(delegate(string accessToken)
			{
				string urlFormat = string.Format("http://api.weixin.qq.com/cgi-bin/api_getwxcategory?access_token={0}", accessToken);
				return CommonJsonSend.Send<GetCategoryResult>(null, urlFormat, null, CommonJsonSendType.GET, 10000, false);
			}, accessTokenOrAppId, true);
		}
	}
}
